import { useIntervalFn } from '@vueuse/core'
import { ref } from 'vue'
export function useCountDown () {
  const countTime = ref(0)
  const { pause, resume, isActive } = useIntervalFn(() => {
    /* your function */
    if (countTime.value === 0) {
      return
    }
    console.log(isActive.value)
    countTime.value--
  }, 1000)

  // 开启
  function start (time) {
    countTime.value = time
    resume()
  }

  // 暂停
  function stop () {
    pause()
  }

  return {
    stop,
    start,
    countTime,
    isActive

  }
}
